package adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.bigchun.seeland.R;

import java.util.List;

import bean.ZhantingListBean;


public class ShaixuanAllAdapter extends BaseAdapter {


    private int checkitem = -1;
    private Context context;
    private LayoutInflater mInflater;
    List<ZhantingListBean.DataBean> mData;
    public ShaixuanAllAdapter(Context context){
        this.mInflater = LayoutInflater.from(context);
    }

    public ShaixuanAllAdapter(Context context, List<ZhantingListBean.DataBean> mData){
        this.context=context;
        this.mInflater = LayoutInflater.from(context);
        this.mData=mData;


    }
    public void setData(List<ZhantingListBean.DataBean> mData,int checkitem){
        this.mData=mData;
        this.checkitem=checkitem;
        notifyDataSetChanged();
    }

    @Override
    public int getCount() {
        return mData.size();
    }

    @Override
    public Object getItem(int arg0) {
        return null;
    }

    @Override
    public long getItemId(int arg0) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if (convertView == null) {

            holder=new ViewHolder();

            convertView = mInflater.inflate(R.layout.item_shaixuanone, null);

            holder.tv_name = (TextView) convertView.findViewById(R.id.tv_name);
            convertView.setTag(holder);

        }else {
            holder = (ViewHolder)convertView.getTag();
        }
        holder.tv_name.setText(mData.get(position).getName());

        if (checkitem == position){
            holder.tv_name.setTextColor(context.getResources().getColor(R.color.colordorange));
        }else{
            holder.tv_name.setTextColor(context.getResources().getColor(R.color.color333));
        }



        return convertView;
    }

    public static class ViewHolder{

        TextView tv_name ;



    }


}